<script>
import bmdForm from '@/components/DmbForm'
import { defaultForm, formBase, tableBase, cellStyle, headerCellStyle, tableFormStyle, formItemStyle } from './config'
import dmbTable from '@/components/LTable/index.vue'
import { mapState } from 'vuex'

export default {
  name: 'jettison',
  computed: {
    ...mapState({
      company: state => state.custom_dict.company
    }),
    headerCellStyle() {
      return headerCellStyle
    },
    tableFormStyle() {
      return tableFormStyle
    },
    cellStyle() {
      return cellStyle
    },
    formItemStyle() {
      return formItemStyle
    }
  },
  components: { bmdForm, dmbTable },
  data() {
    return {
      propsSearchForm: { ...defaultForm },
      requestConfig: {
        url: '/base/manageCargoType/queryDeclarationInfoByCourierNumber',
        method: 'get',
        montage: true
      },
      setRequest: {
        url: '/base/manageCargoType/updateCargoTypeByCourierNumber',
        method: 'put',
        montage: false
      },
      selectionArr: [] // 多选框内容
    }
  },
  methods: {
    tableBase() {
      return tableBase
    },
    formBase() {
      return formBase
    },
    getData() {
      if(this.propsSearchForm.courierNumber && this.propsSearchForm.courierNumber.length > 0) {
        this.$refs.table.getListData()
      } else {
        this.$message.error('快递单号不可为空!')
      }
    }
  }
}
</script>

<template>
  <div>
    <div class="my-3 flex">
      <bmd-form
        ref="form"
        :form-items="formBase()"
        :model-value="propsSearchForm"
        :item-style="formItemStyle"
        @update="(row) => propsSearchForm = row"
        class="flex-1"
      />
      <div>
        <el-button type="success" @click="getData()">查询</el-button>
      </div>
    </div>
    <div>
      <dmbTable
        ref="table"
        :prop-list="tableBase()"
        :is-operate="true"
        :show-index-column="true"
        select-column-type="none"
        :props-search-form="propsSearchForm"
        :req-request="requestConfig"
        :set-request="setRequest"
        select-key="id"
        :cell-style="cellStyle"
        :header-cell-style="headerCellStyle"
        :initialize="false"
        :change-search-form="false"
        :show-footer="true"
        :form-item-style="tableFormStyle"
        @selectionChange="(row) => { selectionArr = row }"
      />
    </div>
  </div>
</template>

<style scoped lang="scss">

</style>
